
import { Button } from 'antd'
import { Input } from 'antd'

function createEditorConfig() {

  // 物料列表
  const componentList = []
  // 物料映射关系
  const componentMap = {}

  return {
    componentList,
    componentMap,
    register: (component) => {
      componentList.push(component)
      componentMap[component.key] = component
    }
  }
}

let registerConfig = createEditorConfig()

export default registerConfig

registerConfig.register({
  label: '文本',
  preview: () => '预览文本',
  render: () => '渲染文本',
  key: 'text'
})

registerConfig.register({
  label: '按钮',
  preview: () => <Button>预览按钮</Button>,
  render: () => <Button>渲染按钮</Button>,
  key: 'button'
})

registerConfig.register({
  label: '输入框',
  preview: () => <Input placeholder='预览输入框' />,
  render: () => <Input placeholder='渲染输入框' />,
  key: 'input'
})